export function initScreenInfo(id) {
  return {
    id: id,
    name: "",
    width: 1920,
    height: 1080,
    remark: "",
    color: "#38322f",
    image: ""
  }
}

export function getScreenStyle(screen) {
  let style = {
    width: screen.width + "px",
    height: screen.height + "px",
  }
  if (screen.image) {
    style.backgroundImage = "url(" + screen.image + ")";
    style.backgroundSize = "100% 100%";
  }
  if (screen.color) {
    style.backgroundColor = screen.color;
  }
  return style;
}

export function divideRuler(length) {
  let array = [];
  for (let i = 0; i <= length; i++) {
    if (i % 50 === 0) {
      array.push(i);
    }
  }
  return array;
}

export function changeArrayItemIndex(array, index, target) {
  if (index === target || target < 0 ||
    array.length < index || array.length < target) {
    return;
  }
  array.splice(target, 0, array.splice(index, 1)[0]);
}